package com.tq.framework.context;

import com.tq.framework.beans.BeanDefinition;
import com.tq.framework.context.annotation.ClassPathScanningCandidateComponentProvider;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

/**
 * 手写简易版Spring Framework
 *
 * @author TqCoder
 * @since 2.0.0
 */
@Slf4j
public class AnnotationConfigApplicationContext {

    private final ClassPathScanningCandidateComponentProvider scanner;

    public AnnotationConfigApplicationContext(String packageName) throws IOException {
        this.scanner = new ClassPathScanningCandidateComponentProvider();
        initContext(packageName);
    }

    public void initContext(String packageName) throws IOException {
        scanner.findCandidateComponents(packageName)
                .forEach(this::createBean);
    }

    public void createBean(BeanDefinition beanDefinition) {
        // TODO: 实现bean的创建逻辑
    }
}
